package com.yanfan.energy.domain.enums;

/**
 * 能源大类分类
 */
public enum EnergyClassifyEnum {

    WATER(1, "水"), ELECTRICITY(2, "电"), AIR(3, "气");


    private Integer code;

    private String desc;

    EnergyClassifyEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据枚举type 返回String类型
     *
     * @param type
     * @return
     */
    public static EnergyClassifyEnum getEnumByType(Integer type) {
        for (EnergyClassifyEnum item : EnergyClassifyEnum.values()) {
            if (item.getCode().equals(type)) {
                return item;
            }
        }
        throw new RuntimeException("通过type获取枚举类时出现异常！");
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


}
